from flask import Flask, render_template, url_for, request
import os
from flask_sqlalchemy import SQLAlchemy
import pymysql
pymysql.inatll_as_MySQLdb()


app = Flask(__name__, static_url_path='/static', static_folder='static', template_folder='templates')
app.config['SECRET_KEY'] = os.urandom(24)

# 使用集成方式处理sqalchem
app.config['SQLALCHEMY_DATABASE_URI']='mysql://root:root@localhost:3306/note?charset=utf8'
app.config['SQLALCHEMY_TRACK_MODFICATIONS']=False
# 实例化
db = SQLAlchemy(app)
# 404页面
@app.errorhandler(404)
def page_not_found(e):
    return render_template('error-404.html')

# 500页面
@app.errorhandler(500)
def page_not_found(e):
    return render_template('error-500.html')


if __name__ == '__main__':
    app.run(debug=True)
